package com.wgworkshop.pems.controller;

import com.wgworkshop.pems.common.ResponseData;
import com.wgworkshop.pems.model.ClassArrangeModel;
import com.wgworkshop.pems.model.ClassHourModel;
import com.wgworkshop.pems.model.HistoryModel;
import com.wgworkshop.pems.service.ClassArrangeService;
import com.wgworkshop.pems.service.ClassHourService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 历史控制器（缴费历史、班级安排历史）。
 * Created by wlc on 2017/10/11.
 */
@RestController
@RequestMapping("/histories")
public class HistoryController {
    @Autowired
    private ClassHourService classHourService;
    @Autowired
    private ClassArrangeService classArrangeService;

    @GetMapping("/student/{id}")
    ResponseData<HistoryModel> findByStudentId(@PathVariable("id") Long id) {
        List<ClassHourModel> classHourHistories = classHourService.findByStudentId(id);
        List<ClassArrangeModel> classArrangeHistories = classArrangeService.findByStudentId(id);

        HistoryModel historyModel = new HistoryModel();
        historyModel.setClassHourHistories(classHourHistories);
        historyModel.setClassArrangeHistories(classArrangeHistories);

        return new ResponseData<HistoryModel>().success(historyModel);
    }
}
